~ chicken-core (master) /manual/Module (chicken pathname)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken pathname)56This module provides procedures for manipulating paths. If you want7to operate on the files and directories which the paths represent, see8[[Module (chicken file)]].910=== absolute-pathname?1112<procedure>(absolute-pathname? PATHNAME)</procedure>1314Returns {{#t}} if the string {{PATHNAME}} names an absolute15pathname, and returns {{#f}} otherwise.1617=== decompose-pathname1819<procedure>(decompose-pathname PATHNAME)</procedure>2021Returns three values: the directory-, filename- and extension-components22of the file named by the string {{PATHNAME}}.23For any component that is not contained in {{PATHNAME}}, {{#f}} is returned.2425=== make-pathname26=== make-absolute-pathname2728<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION])</procedure><br>29<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION])</procedure>3031Returns a string that names the file with the32components {{DIRECTORY, FILENAME}} and (optionally)33{{EXTENSION}} with {{SEPARATOR}} being the directory separation indicator34({{/}}).35{{DIRECTORY}} can be {{#f}} (meaning no36directory component), a string or a list of strings. {{FILENAME}}37and {{EXTENSION}} should be strings or {{#f}}.38{{make-absolute-pathname}} returns always an absolute pathname.3940=== pathname-directory41=== pathname-file42=== pathname-extension4344<procedure>(pathname-directory PATHNAME)</procedure><br>45<procedure>(pathname-file PATHNAME)</procedure><br>46<procedure>(pathname-extension PATHNAME)</procedure>4748Accessors for the components of {{PATHNAME}}. If the pathname does49not contain the accessed component, then {{#f}} is returned.5051=== pathname-replace-directory52=== pathname-replace-file53=== pathname-replace-extension5455<procedure>(pathname-replace-directory PATHNAME DIRECTORY)</procedure><br>56<procedure>(pathname-replace-file PATHNAME FILENAME)</procedure><br>57<procedure>(pathname-replace-extension PATHNAME EXTENSION)</procedure>5859Return a new pathname with the specified component of {{PATHNAME}}60replaced by a new value.6162=== pathname-strip-directory63=== pathname-strip-extension6465<procedure>(pathname-strip-directory PATHNAME)</procedure><br>66<procedure>(pathname-strip-extension PATHNAME)</procedure>6768Return a new pathname with the specified component of {{PATHNAME}}69stripped.7071=== normalize-pathname7273<procedure>(normalize-pathname PATHNAME [PLATFORM])</procedure>7475Performs a simple "normalization" on the {{PATHNAME}}, suitably for76{{PLATFORM}}, which should be one of the symbols {{windows}}77or {{unix}} and defaults to on whatever platform is currently78in use. All relative path elements and duplicate separators are processed79and removed. If {{NAME}} ends with80a {{/}} or is empty, a slash is appended to the tail.8182No directories or files are actually tested for existence; this83procedure only canonicalises path syntax.8485=== directory-null?8687<procedure>(directory-null? DIRECTORY)</procedure>8889Does the {{DIRECTORY}} consist only of path separators and the period?9091{{DIRECTORY}} may be a string or a list of strings.9293=== decompose-directory9495<procedure>(decompose-directory DIRECTORY)</procedure>9697Returns 3 values: the {{base-origin}}, {{base-directory}}, and the98{{directory-elements}} for the {{DIRECTORY}}.99100; {{base-origin}} : a {{string}} or {{#f}}. The drive, if any.101; {{base-directory}} : a {{string}} or {{#f}}. A directory-separator when {{DIRECTORY}} is an {{absolute-pathname}}.102; {{directory-elements}} : a {{list-of string}} or {{#f}}. The non-directory-separator bits.103104{{DIRECTORY}} is a {{string}}.105106* On Windows {{(decompose-directory "c:foo/bar")}} => {{"c:" #f ("foo" "bar")}}107108=== Windows specific notes109110Use of UTF8 encoded strings for pathnames is not supported. Windows111uses a 16-bit UNICODE encoding with special system calls for112wide-character support. Only single-byte string encoding can be used.113114---115Previous: [[Module (chicken number-vector)]]116117Next: [[Module (chicken platform)]]